package Pet.Management.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import Pet.Management.domain.entity.PetCareAcceptor;
import java.util.Optional;

public interface PetCareAcceptorRepository extends JpaRepository<PetCareAcceptor, Long> {
    
    @Query("SELECT a FROM PetCareAcceptor a WHERE " +
           "LOWER(a.user.username) LIKE LOWER(CONCAT('%', :search, '%')) OR " +
           "LOWER(a.goodAtPetType) LIKE LOWER(CONCAT('%', :search, '%'))")
    Page<PetCareAcceptor> searchAcceptors(@Param("search") String search, Pageable pageable);
    
    Page<PetCareAcceptor> findByStatus(Integer status, Pageable pageable);

    Optional<PetCareAcceptor> findByUserId(Long userId);
} 